//
//  ConversationListDataBase.h
//  AAIM
//
//  Created by awh on 2019/12/23.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@class BTMessageModel;

@interface ConversationListDataBase : NSObject
+ (instancetype)shareConversationListDataBase;

// 创表，登录成功后调用
- (void)createTable;

// 增、改
- (void)saveConversation:(BTMessageModel *)msg;

// 清空content，用于删除聊天记录时使用
- (void)clearConversationContentWithChatType:(ChatType)chatType uidOrGroupId:(NSInteger)uidOrGroupId;


// 删除
- (void)deleteConversationWithChatType:(ChatType)chatType uidOrGroupId:(NSInteger)uidOrGroupId;

// 根据keyid删除
- (void)deleteConversationWithKeyid:(NSString *)keyid;

// 清空会话列表
- (void)clearConversations;

/**
 更新消息提醒状态
 
 @param chatType 单聊或群聊
 @param uidOrGroupId 单聊为对方id， 群聊为群id
 @param isIgnore 是否屏蔽通知
 */
- (void)updateMessageIgnoreStatusWithChatType:(ChatType)chatType uidOrGroupId:(NSInteger)uidOrGroupId isIgnore:(BOOL)isIgnore;

/**
 更新是否置顶聊天
 
 @param chatType 单聊或群聊
 @param uidOrGroupId 单聊为对方id， 群聊为群id
 @param isTop 是否置顶
 */
- (void)updateConversationTopStatusWithChatType:(ChatType)chatType uidOrGroupId:(NSInteger)uidOrGroupId isTop:(BOOL)isTop;

// 根据时间戳清空该消息的未读消息数
- (void)clearUnreadCount:(BTMessageModel *)msg;

// 清除@
- (void)clearAtWithMessage:(BTMessageModel *)msg;

// 查找当前登录用户的全部会话
- (NSArray<BTMessageModel *> *)queryAllConversations;

// 获取单条会话信息
- (BTMessageModel *)converationWithChatType:(ChatType)chatType uidOrGroupId:(NSInteger)uidOrGroupId;

// 获取未读消息数（不包括屏蔽会话）
- (NSInteger)totalUnreadCount;

@end

NS_ASSUME_NONNULL_END
